package logrus_plugin

import (
	"gitee.com/kristas/booting-go/framework/core/log"
	"gitee.com/kristas/booting-go/framework/core/statement/types"
	"github.com/sirupsen/logrus"
)

type LoggerAdapter struct {
	types.Component `name:"logrus-log"`
	Logger          *logrus.Logger
}

func NewLoggerAdapter() *LoggerAdapter {
	logger := logrus.New()
	logger.SetReportCaller(true)
	logger.SetFormatter(&Formatter{})
	logger.SetLevel(logrus.TraceLevel)
	return &LoggerAdapter{Logger: logger}
}

func (l *LoggerAdapter) Trace(a string, meta *log.Meta) {
	l.Logger.Trace(a)
}

func (l *LoggerAdapter) Debug(a string, meta *log.Meta) {
	l.Logger.Debug(a)
}

func (l *LoggerAdapter) Info(a string, meta *log.Meta) {
	l.Logger.Info(a)
}

func (l *LoggerAdapter) Warn(a string, meta *log.Meta) {
	l.Logger.Warn(a)
}

func (l *LoggerAdapter) Error(a string, meta *log.Meta) {
	l.Logger.Error(a)
}

func (l *LoggerAdapter) Panic(a string, meta *log.Meta) {
	l.Logger.Panic(a)
}

func (l *LoggerAdapter) Fatal(a string, meta *log.Meta) {
	l.Logger.Fatal(a)
}
